<?php

namespace app\index\controller;

use think\Controller;

class Btc extends Controller
{
    public function index()
    {
        return $this->fetch();
    }

    public function getPrice()
    {
        $url = 'https://blockchain.info/ticker';

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        // 将curl_exec()获取的信息以字符串返回，而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        // 设定为 不验证SSL证书和HOST
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

        $data = curl_exec($curl);
        // curl_close($curl);
        // var_dump($data);
        echo $data;
    }


}
